package com.yykj.backstage.all.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yykj.backstage.all.dto.TouSuCreateDTO;
import com.yykj.backstage.all.dto.TouSuFixDTO;
import com.yykj.backstage.all.dto.TouSuSearchDTO;
import com.yykj.backstage.all.model.entity.TouSu;
import com.yykj.backstage.all.model.entity.TouSuType;
import com.yykj.backstage.all.service.TouSuService;
import com.yykj.common.vo.PageData;
import com.yykj.common.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/backstage/all/tou/su")
@Api(tags = "投诉相关接口")
@SuppressWarnings(value = "unchecked")
public class TouSuController {

    @PostMapping("/type/edit")
    @ApiOperation("投诉类型-- 添加修改")
    public ResultVO<TouSuType> editTouSuType(@RequestBody TouSuType type){
        return ResultVO.success(touSuService.editTouSuType(type));
    }

    @DeleteMapping("/type/delete/{id}")
    @ApiOperation("投诉类型-- 删除")
    public ResultVO deleteTouSuType(@PathVariable Integer id){
        touSuService.deleteTouSuType(id);
        return ResultVO.success();
    }


    @GetMapping("/type/list")
    @ApiOperation("投诉类型-- 列表")
    public ResultVO<List<TouSuType>> listTouSuType(){
        return ResultVO.success(touSuService.listTouSuType());
    }

    //===========================================================================================================

    @GetMapping("/list")
    @ApiOperation("投诉 -- 列表")
    public ResultVO<PageData<TouSu>> listTouSu( TouSuSearchDTO touSuSearchDTO){
        return ResultVO.success(touSuService.listTouSu(touSuSearchDTO));
    }

    @PostMapping("/fix")
    @ApiOperation("投诉 -- 审核 ")
    public ResultVO fixTouSu(@RequestBody TouSuFixDTO fixDTO){
        touSuService.fixTouSu(fixDTO);
        return ResultVO.success();
    }

    @PostMapping("/create")
    @ApiOperation("投诉 -- 创建 ")
    @ApiOperationSupport(ignoreParameters = {"addTime","fixTime","id","remark","status"})
    public ResultVO<TouSu> createTouSu(@RequestBody TouSuCreateDTO touSu){
        return ResultVO.success(touSuService.createTouSu(touSu));
    }


    private TouSuService touSuService;

    @Autowired
    public void setTouSuService(TouSuService touSuService) {
        this.touSuService = touSuService;
    }
}
